//
//  CircleViewTableViewCell.swift
//  OnceNectar
//
//  Created by 法正磊 on 2018/2/7.
//  Copyright © 2018年 com.inwhoop. All rights reserved.
//

import UIKit
protocol CircleViewTableViewCellDelegate: NSObjectProtocol {
    func joinTap(model:CircleModel)
}
class CircleViewTableViewCell: UITableViewCell {

    @IBOutlet weak var joinBtn: UIButton!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var headImgView: BaseCircleImageView!
    weak var delegate: CircleViewTableViewCellDelegate?
    var model:CircleModel?
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    @IBAction func joinTap(_ sender: UIButton) {
        self.delegate?.joinTap(model: self.model!)
    }
    @IBAction func shareTap(_ sender: UIButton) {
        ReportView().show(contnets: nil, type: .share) { (index, view) in
            print(index)
            view.hide()
        }
        
    }
    @IBAction func collectionTap(_ sender: UIButton) {
        
    }
    
    func showData(model: CircleModel) {
        self.nameLabel.text = model.circleName!
        self.model = model
        let path:String = "\(BaseURL)\(model.coverPath!)"
        
        
        if model.beJoined! == "1" {
            self.joinBtn.setTitle("退出", for: UIControlState.normal)
        } else {
            self.joinBtn.setTitle("进入", for: UIControlState.normal)
        }
        
        let url = NSURL.init(string: path.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)
        headImgView.sd_setImage(with: url! as URL, completed: nil)


    }
}
